home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Media Design Review 1999
/
Interactive Media Design Review 1999.iso
/
pc
/
Demos
/
Bombardier_PC
/
DATACH.CST
/
00001_Script_1
next >
Wrap
Text File
|
1999-03-07
|
32KB
|
960 lines
-- database routines
global DBRECORD
global DBHANDLE
-- init database pointers
on initDBch
global currentdb
if (currentdb = "aircraft.mdb") and (DBHANDLE>0) then
nothing
else
-- alert ("loading databasech" & currentdb)
set currentdb = "aircraft.mdb"
if objectp(DBHANDLE) then
DGclose(DBHANDLE)
set DBHANDLE = 0
end if
-- set DBHANDLE = DGopenDataBase("aircraft.mdb")
set dbHandle = DGOpenDatabase(the moviePath & "aircraft.mdb")
if dbHandle = "#ERROR#" then
alert "Error: " & GetLastDGError()
alert "open db."
ClearDGError()
--quit
end if
end if
end
-- set current plane global based on movie name
-- and set flags for reread of data when planes change
on initcurrentplane
global CurrentPlane, cheraseflag
global flag_Hour, flag_specs, oldmoviename
set tCurrentPlane = "test"
-- alert(the movieName & " vs. " & CurrentPlane)
if the movieName <> oldmoviename then
set oldmoviename = the movieName
if the movieName = "Global.dir" then set tCurrentPlane = "Global Express"
if the movieName = "Se.dir" then set tCurrentPlane = "Canadair SE"
if the movieName = "CH604.dir" then set tCurrentPlane = "Challenger 604"
if the movieName = "Lear31a.dir" then set tCurrentPlane = "Learjet 31a"
if the movieName = "Lear45.dir" then set tCurrentPlane = "Learjet 45"
if the movieName = "Lear60.dir" then set tCurrentPlane = "Learjet 60"
set cheraseflag = TRUE
set flag_Hour = TRUE
set flag_specs = TRUE
set CurrentPlane = tCurrentPlane
end if
end
-- fill database using field names as database reference
--
-- note: 1st char of castmember name is formating character
-- as follows: F - feet
-- S - Square Feet
-- A - Cubic Feet
-- D - Degree
-- N - decimal if under 10 otherwise integer only
-- M - Mach
-- U - Knots
-- Y - Nautical Miles
-- I - Inch
-- W - Lps
-- X - Feet per Second
-- K - Time (in HH:MM)
-- T - Text (no translation)
-- P - Percent %
-- Z - feet per minute
-- Remaining characters should exactly match database field names
--
-- Pass routine membernum of 1st database field to fill, will continue filling
-- castmembers until it reaches a castmember named "***end***"
on fillDataBaseFields startingcast
global togglestate
set currentDBcast = startingcast
set the floatPrecision = 2
repeat while true
set findname = the name of member currentDBcast
if findname = "***end***" then
exit repeat
else
set chFormat = char 1 of findname
delete char 1 of findname
-- put findname
set tempdata = DGRSgetFieldValue(findname,DBRECORD)
if tempdata = "#ERROR#" then
put "error:"&&GetLastDGError()&&findname
else
if togglestate = 0 then -- standard numbering (imperial)
case (chformat) of
"F":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & " ft"
"S":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) &" ft" & numtochar(178)
"A":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & " ft" & numtochar(179)
"D":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & " deg"
"N":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum)
"M":
set the floatPrecision = 2
set outnum = float(value(tempdata))
set tempdata = "M" & string(outnum)
"P":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & "%"
"U":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & " kts"
"Y":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & " nm"
"I":
set outnum = float(value(tempdata))
set tempdata = formatch(integer(outnum)) & " in"
"W":
set outnum = float(value(tempdata))
set tempdata = formatch(integer(outnum)) & " lbs"
"X":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & " ft/sec"
"Z":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & " ft/min"
"K":
set xch = the number of chars in tempdata
set tempdata = char 1 to (xch - 6) of tempdata
"T":
-- set tempdata = string(tempdata)
end case
else -- metric conversion
case (chformat) of
"F":
set outnum = float(value(tempdata))
set outnum2 = float(outnum * .30480)
set tempdata = formatch(outnum2) & " m"
"S":
set outnum = float(value(tempdata))
set outnum2 = float(outnum * .092903)
set tempdata = formatch(outnum2) & " m" & numtochar(178)
"A":
set outnum = float(value(tempdata))
set outnum2 = float(outnum * .028317)
set tempdata = formatch(outnum) & " m" & numtochar(179)
"D":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & " deg"
"N":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum)
"M":
set the floatPrecision = 2
set outnum = float(value(tempdata))
set tempdata = "M" & string(outnum)
"P":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & "%"
"U":
set outnum = float(value(tempdata))
set tempdata = formatch(outnum) & " kts"
"Y":
set outnum = float(value(tempdata))
set outnum2 = float(1.8520 * outnum)
set tempdata = formatch(outnum2) & " km"
"I":
set outnum = float(value(tempdata))
set outnum2 = float(outnum * 2.54)
set tempdata = formatch(outnum2) & " cm"
"W":
set outnum = float(value(tempdata))
set outnum2 = float(outnum * .45359)
set tempdata = formatch(outnum2) & " kg"
"X":
set outnum = float(value(tempdata))
set outnum2 = float(outnum * .30480)
set tempdata = formatch(outnum2) & " m/sec"
"Z":
set outnum = float(value(tempdata))
set outnum2 = float(outnum * .30480)
set tempdata = formatch(outnum2) & " m/min"
"T":
-- set tempdata = string(tempdata)
end case
end if
end if
set the text of member currentDBcast = string(tempdata)
end if
set currentDBcast = currentDBcast + 1
end repeat
end
-- fill specifications screen variables
--
-- open data table and call routine to fill fields
on fillspecs dataplanename, startingcast
set DBRECORD = DGcreateRecordset("SELECT * FROM Aircrafts", DBHANDLE)
set chquery = "Aircraft = " & QUOTE & dataplanename & QUOTE
set outresult =DGRSfindFirst(chquery, DBRECORD)
-- put dataplanename & " - "outresult & "= out"
if outresult<> 0 then
fillDataBaseFields(startingcast)
else
alert("not found-"&dataplanename)
end if
if DGRSIsOpen(DBRECORD) then
DGRSClose(DBRECORD)
end if
end
-- fill configuration screen variables
--
-- open data table and call routine to fill fields
on fillconfig dataplanename, startingcast
set DBRECORD = DGcreateRecordset("SELECT * FROM Configurations", DBHANDLE)
set chquery = "Aircraft = " & QUOTE & dataplanename & QUOTE
DGRSfindFirst(chquery, DBRECORD)
fillDataBaseFields(startingcast)
if DGRSIsOpen(DBRECORD) then
DGRSClose(DBRECORD)
end if
end
--InitDB set dbhandle to database dbname if not already loaded
on InitDB dbName
global currentdb
if (currentdb = dbname) and (DBHANDLE>0) then
nothing
else
-- alert ("loading database :" & currentdb & ":" & objectp(DBHANDLE) )
set currentdb = dbname
if objectp(DBHANDLE) then
DGclose(DBHANDLE)
set DBHANDLE = 0
end if
set dbHandle = DGOpenDatabase(the moviePath & dbName)
if dbHandle = "#ERROR#" then
alert "Error: " & GetLastDGError()
alert "open db."
ClearDGError()
--quit
end if
end if
end
-- routines called from popups
-- change plane for bjs datasheets
-- airplanename = plane to change data to look at
on Disbjs airplanename
global gxcompetitor
global currentChartName, currentplane, chCompDisplay
-- put "plane =" & airplanename
set the text of member "disPlane" to airplanename
set currentplane = airplanename
disincome airplanename
end
-- change plane for 1 of 3 colums in bjs
-- airplanename = plane to change to
-- columused = colum of data to fill
on Disbjscol airplanename, columused
global gxcompetitor
global currentChartName, currentplane, chCompDisplay
if airplanename = "NONE" then
bjsclearcolum(columused)
else
-- put "plane =" & airplanename
set the text of member "disPlanecol"&columused to airplanename
set the text of member "disPercentcol"&columused to "1/8"
calcFReportsingle(columused)
end if
end
-- change percent of ownership for 1 of 3 colums in bjs
-- airplanepercent = percent to change to
-- columused = colum of data to fill
on Disbjsfraction airplanepercent, columused
global gxcompetitor
global currentChartName, currentplane, chCompDisplay
-- put "plane =" & airplanepercent
set the text of member "disPercentcol"&columused to airplanepercent
calcFReportsingle(columused)
end
-- called from plane popups to change competitor
-- airplanename = plane to compare
on DisSpecs airplanename
global gxcompetitor
global currentChartName, currentplane, chCompDisplay
global Out_Text
watchcursor()
-- put "plane =" & airplanename
set the text of member "disPlane" to airplanename
set the text of member "aacplanename" to airplanename
if airplanename = "NONE" then
set the text of member "disPlane" = "No Competitor"
set the text of member "aacplanename" = "No Competitor"
end if
if currentChartName = "all" then
if airplanename = "NONE" then
-- clear fields for competitive aircraft
set xcastnum = ( the number of member "CHDBdaircrafts" ) + 1
erasedatabasefields(xcastnum)
set xcastnum = ( the number of member "CHDBdconfig" ) + 1
erasedatabasefields(xcastnum)
else
-- put in data for specifications screens
set xcastnum = ( the number of member "CHDBdaircrafts" ) + 1
fillspecs(airplanename, xcastnum)
set xcastnum = ( the number of member "CHDBdconfig" ) + 1
fillconfig(airplanename, xcastnum)
end if
-- updatestage
else
if currentChartName = "Range_maps" then
getassumptions()
set the text of field "gxassumptions" = Out_Text
if airplanename <> "NONE" then
-- fill in range data for competitor
set gxcompetitor = airplanename
fillgxcompetitor
else
-- erase range competitor
set gxcompetitor = "No Competitor"
repeat with sx = 11 to 14
set cx = the member of sprite sx
set the text of member cx = " "
end repeat
set cx = the member of sprite 6
set the text of member cx = " "
set cx = the member of sprite 16
set the text of member cx = " "
end if
else
-- performace graph
if chCompDisplay <> "" then
go to "chartblank"
updatestage
go to "chartback"
updatestage
chewchart(currentplane,currentplane, 14) -- redraw main planes chart
end if
getassumptions()
set the text of field "chartassumptions" = Out_Text
if airplanename <> "NONE" then
chewchart(currentplane,airplanename, 15) -- draw competitor chart
set chCompDisplay = airplanename
end if
end if
end if
arrowcursor()
end
-- fill specification screen for main plane
on MainSpecs airplanename
global currentPlane
set airplanename to currentPlane
set xcastnum = ( the number of member "CHDBaircrafts" ) + 1
fillspecs(airplanename, xcastnum)
set xcastnum = ( the number of member "CHDBconfig" ) + 1
fillconfig(airplanename, xcastnum)
updatestage
end
-- set cursors to indicate system activity
on watchcursor
set watchy = the number of member "watch_cursor"
set watchmsk = the number of member "watch_cursor_mask"
cursor [watchy, watchmsk]
end
on arrowcursor
cursor -1
end
-- read values for specification screens
on setupspecs
-- ch added (set current plane)
watchcursor()
global currentPlane
global DBRECORD, DBHANDLE
global currentChartName
initcurrentplane -- get back plane name
-- set currentplane = "Learjet 31a"
set currentChartName = "all"
-- set DBRECORD = 0
-- set DBHANDLE = 0
getaircrafts -- fill competitor popups
-- initdbch
mainspecs
-- dispecs
arrowcursor()
end
-- unpuppet all sprites used
on clearpups
repeat with spx = 2 to 59
set the visible of sprite spx = true
puppetsprite spx, false
end repeat
end
--- Range Maps
-- fill data screens for range maps based on globals set
on fillGXdata
global gxnewmember, gxcity
global currentplane
global gxsprite, gxpair
global gxcompetitor
global Out_Text
watchcursor()
puppetsprite 2, true
set the member of sprite 2 = gxnewmember -- change background map
-- get data from query
-- open query
set qdHandle =DGQDOpen("Range_MapValues",dbHandle)
if qdHandle="#ERROR#" then
alert "Error:"&&GetLastDGError()
end if
-- set parameters for query
if DGQDsetParameterValue("Bomb plane", currentplane, qdhandle) = "#ERROR#" then
put "b:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Model", currentplane, qdhandle) = "#ERROR#" then
put "p:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Range_Maps.City", GXcity, qdhandle) = "#ERROR#" then
put "c:"&&GetLastDGError()
end if
-- execute query (get recordset)
set DBRECORD=DGQDCreateRS(qdHandle)
if DBRECORD = "#ERROR#" then
alert "DB ERROR - (No city?)"
else
set xcastnum = ( the number of member "CHDBmainrange" ) + 1
fillDataBaseFields(xcastnum)
set tempspeed = getfieldvalue(xcastnum,"TSpeed")
if tempspeed < 10 then
set tempdist = getfieldvalue(xcastnum,"TESAD")
setfieldvalue(xcastnum, "TDistance", tempdist)
end if
set chpax = DGRSGetFieldValue("Pax",DBRECORD)
set the text of field "aPax" = string(chpax)
set chpax = DGRSGetFieldValue("typical corporate bow",DBRECORD)
set the text of field "agxweight" = string(chpax)
updatestage
-- close database
if DGQDIsOpen(qdhandle) then
DGQDClose(qdhandle)
end if
if DGRSIsOpen(DBRECORD) then
DGRSClose(DBRECORD)
end if
end if
-- fill competitor fields (if there is one)
if gxcompetitor <> "No Competitor" then
fillgxcompetitor
end if
getassumptions
set the text of field "gxassumptions" = Out_Text
arrowcursor()
end
-- fill range maps competitor figures
on fillgxcompetitor
global gxnewmember, gxcity
global currentplane
global gxcompetitor
global DBRECORD
watchcursor()
-- get data from query (if there is a city chosen)
if length(GXcity) > 3 then
set qdHandle =DGQDOpen("Range_MapValues",dbHandle)
if qdHandle="#ERROR#" then
alert "Error:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Bomb plane", currentplane, qdhandle) = "#ERROR#" then
put "b:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Model", gxcompetitor, qdhandle) = "#ERROR#" then
put "p:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Range_Maps.City", GXcity, qdhandle) = "#ERROR#" then
put "c:"&&GetLastDGError()
end if
set DBRECORD=DGQDCreateRS(qdHandle)
if DBRECORD = "#ERROR#" then
alert "DB ERROR - (No city?)"
else
set xcastnum = ( the number of member "CHDBcomprange" ) + 1
fillDataBaseFields(xcastnum)
set tempspeed = getfieldvalue(xcastnum,"TSpeed")
if tempspeed < 10 then
set tempdist = getfieldvalue(xcastnum,"TESAD")
setfieldvalue(xcastnum, "TDistance", tempdist)
end if
set isroute = DGRSGetFieldValuech("Route_Capability",DBRECORD)
if isroute = "#ERROR#" then
set the text of field "cPax" = " "
set the text of field "cgxweight" = " "
set xcastnum = ( the number of member "CHDBcomprange" ) + 1
junkDataBaseFields(xcastnum,"Not Possible")
else
if isroute then
set chpax = DGRSGetFieldValue("Pax",DBRECORD)
set the text of field "cPax" = string(chpax)
set chpax = DGRSGetFieldValue("typical corporate bow",DBRECORD)
set the text of field "cgxweight" = string(chpax)
else
set the text of field "cPax" = " "
set the text of field "cgxweight" = " "
set xcastnum = ( the number of member "CHDBcomprange" ) + 1
junkDataBaseFields(xcastnum,"Not Possible")
end if
end if
updatestage
if DGQDIsOpen(qdhandle) then
DGQDClose(qdhandle)
end if
if DGRSIsOpen(DBRECORD) then
DGRSClose(DBRECORD)
end if
end if
end if
arrowcursor()
end
-- clear out bjs income totals
on clearincomstotals
repeat with i = 1 to 6
set the text of field "incret"&i = " "
end repeat
end
-- Charting Routines
--
-- Draw a line
-- spritenum = sprite # to draw with (trails on)
-- sx = starting x, sy = starting y
-- ex = ending x, ey = ending y
on drawaLine spritenum, sx, sy, ex, ey
global chartrect_left, chartrect_right, chartrect_top, chartrect_bottom
global Start_x, End_x, Start_y, End_y, Increment_x, Increment_y
-- limit numbers to usable values (on Y axis)
if start_y < End_y then
if sy < start_y then
set sy = start_y
end if
if sy > end_y then
set sy = end_y
end if
if ey < start_y then
set ey = start_y
end if
if ey > end_y then
set ey = end_y
end if
else
if sy > start_y then
set sy = start_y
end if
if sy < end_y then
set sy = end_y
end if
if ey > start_y then
set ey = start_y
end if
if ey < end_y then
set ey = end_y
end if
end if
-- limit numbers to usable values (on X axis)
if sx < start_x then
set sx = start_x
end if
if sx > end_x then
set sx = end_x
end if
if ex < start_x then
set ex = start_x
end if
if ex > end_x then
set ex = end_x
end if
-- calculate starting Y Position
if (sy = start_y) then
set startypos = chartrect_bottom
else
set startypos = chartrect_bottom - (1.0 * (sy - start_y) / (End_y - Start_y) * ¼
(chartrect_bottom - chartrect_top))
end if
-- calculate ending Y Position
if (ey = start_y) then
set endypos = chartrect_bottom
else
set endypos = chartrect_bottom - (1.0 * (ey - start_y) / (End_y - Start_y) * ¼
(chartrect_bottom - chartrect_top))
end if
-- calculate starting X Position
if (sx = start_x) then
set startxpos = chartrect_left
else
set startxpos = (1.0 * (sx - start_x) / (End_x - Start_x) * ¼
(chartrect_right - chartrect_left)) + chartrect_left
end if
-- calculate ending X Position
if (ex = start_x) then
set endxpos = chartrect_left
else
set endxpos = (1.0 * (ex - start_x) / (End_x - Start_x) * ¼
(chartrect_right - chartrect_left)) + chartrect_left
end if
-- calculate number of pixel difference
set ylp = abs(endypos - startypos)
set xlp = abs(endxpos - startxpos)
if ylp = xlp then
nothing
else
if ylp > xlp then
set drawloop = ylp
else
set drawloop = xlp
end if
set inc_y = ((endypos - startypos)*100) / drawloop
set inc_x = ((endxpos - startxpos)*100) / drawloop
set cur_x = startxpos * 100
set cur_y = startypos * 100
set the trails of sprite spritenum = true
-- draw the line
repeat with yloop = 1 to drawloop
set the loch of sprite spritenum = (cur_x / 100)
set the locv of sprite spritenum = (cur_y / 100)
updatestage
set cur_x = cur_x + inc_x
set cur_y = cur_y + inc_y
end repeat
set the loch of sprite spritenum = (cur_x / 100)
set the locv of sprite spritenum = (cur_y / 100)
updatestage
end if
end
-- set up globals for chart printing
on setupchart
global paramchartredraw
global Start_x, End_x, Start_y, End_y, Increment_x, Increment_y
global chartrect_left, chartrect_right, chartrect_top, chartrect_bottom
global cLabel_x, cLabel_y, cParam_name, cParam_value
global currentchartname, currentPlane, fixedchartname
global Out_Text
watchcursor()
clearpups
getaircrafts -- fill competitor popups
cleartics() -- erase old screen number tics
go to "chartchange" -- clear old chart from screen
updatestage
go to "chartback"
updatestage
set fixedchartname = spacetounderscore(currentchartname)
set the text of field "dischart" = currentchartname
puppetsprite 9, true
set the member of sprite 9 = fixedchartname
-- set globals of chart from sprite size and position
set chartrect_left = the left of sprite 13
set chartrect_right = the right of sprite 13
set chartrect_top = the top of sprite 13
set chartrect_bottom = the bottom of sprite 13
-- load in chart info from database query and fill globals
set qdHandle =DGQDOpen("CoordinatesValues",dbHandle)
if qdHandle="#ERROR#" then
alert "Error:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Model", currentplane, qdhandle) = "#ERROR#" then
put "p:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Chart Name", fixedChartName, qdhandle) = "#ERROR#" then
put "p:"&&GetLastDGError()
end if
set rsHandle=DGQDCreateRS(qdHandle)
set Start_x = DGRSGetFieldValue("Start-Point-x",rsHandle)
set End_x = DGRSGetFieldValue("End-Point-x",rsHandle)
set Start_y = DGRSGetFieldValue("Start-Point-y",rsHandle)
set End_y = DGRSGetFieldValue("End-Point-y",rsHandle)
set Increment_x = DGRSGetFieldValue("Increments-x",rsHandle)
set Increment_y = DGRSGetFieldValue("Increments-y",rsHandle)
set cLabel_x = DGRSGetFieldValue("Label-X",rsHandle)
set cLabel_y = DGRSGetFieldValue("Label-Y",rsHandle)
-- labels in wrong position - flipped for display
set the text of member "Label-y" = cLabel_x
set the text of member "Label-x" = cLabel_y
if paramchartredraw <> 1 then
set cParam_name = DGRSGetFieldValue("Parameter_Name",rsHandle)
if length(cParam_name) > 3 then
set the text of member "param name" = "Select " & cParam_name
set the visible of sprite 16 = true -- rollover triangle
else
set the text of member "param name" = " "
set the visible of sprite 16 = false
end if
-- parse parameter values for popup list
set paramlist = DGRSGetFieldValue("Parameter_Values",rsHandle)
put "" into field "param list"
set ix = the number of items in paramlist
set outfield = ""
if ix > 1 then
repeat with iloop = 1 to ix
set val = item iloop of paramlist
if char 1 of val = " " then
delete char 1 of val
end if
set cline = the linecount of member "param list"
put val&"" into line cline+1 of field "param list"
end repeat
else
set the text of member "param list" = paramlist
end if
set cParam_value = item 1 of paramlist
set the text of member "current param" = cParam_value
end if
-- close database references
if DGQDIsOpen(qdhandle) then
DGQDClose(qdhandle)
end if
if DGRSIsOpen(rsHandle) then
DGRSClose(rsHandle)
end if
-- draw edge numbers
drawtics()
-- draw the chart
chewchart(currentplane,currentplane, 14)
set airplanename = the text of member "disPlane"
if (length(airplanename) > 4) and (airplanename<>"No Competitor") then
chewchart(currentplane,airplanename, 15) -- draw competitor chart
-- set chCompDisplay = airplanename
end if
getassumptions()
set the text of field "chartassumptions" = Out_Text
arrowcursor()
end
-- erase edge numbers
on cleartics
repeat with xsprnum = 20 to 39
puppetSprite xsprnum, false
end repeat
end
-- draw edge numbers from global variables
on drawtics
global Start_x, End_x, Start_y, End_y, Increment_x, Increment_y
global chartrect_left, chartrect_right, chartrect_top, chartrect_bottom
-- calculate distribution of numbers
set cheight = chartrect_bottom - chartrect_top
set cwidth = chartrect_right - chartrect_left
-- left edge
if Increment_y <> 0 then
set chdiv = (end_y - start_y) / Increment_y
if chdiv < 0 then
set chdiv = 0 - chdiv
set Increment_y = 0 - increment_y
end if
if chdiv > 8 then
set chdiv = 8
set Increment_y = abs((end_y - start_y) / chdiv)
end if
set chadd = cheight / chdiv
set xcastnum = ( the number of member "Left_Tics1" )
set curvalue = Start_y
set curv = chartrect_bottom
repeat with xsprnum = 20 to 39
puppetSprite xsprnum, false
end repeat
updatestage
if abs(end_y - start_y) < 10 then
set the floatPrecision = 2
else
set the floatPrecision = 0
end if
repeat with xsprnum = 20 to 20 + chdiv
set the text of member xcastnum = string(curvalue) & "--"
puppetSprite xsprnum, true
set the locv of sprite xsprnum = curv - 9
set the loch of sprite xsprnum = Chartrect_left - 48
set curvalue = curvalue + Increment_y
set curv = curv - chadd
set xcastnum = xcastnum + 1
end repeat
end if
-- bottom edge
if abs(end_x - start_x) < 10 then
set the floatPrecision = 2
else
set the floatPrecision = 0
end if
if Increment_x <> 0 then
set chdiv = (end_x - start_x) / Increment_x
if chdiv < 0 then
set chdiv = 0 - chdiv
set Increment_x = 0 - increment_x
end if
if chdiv <> 0 then set chadd = cwidth / chdiv
set xcastnum = ( the number of member "Bottom_Tics1" )
set curvalue = Start_x
set curv = chartrect_left
repeat with xsprnum = 30 to 30 + chdiv
set the text of member xcastnum = "|" & RETURN & string(curvalue)
puppetSprite xsprnum, true
set the locv of sprite xsprnum = Chartrect_bottom - 8
set the loch of sprite xsprnum = Curv - 20
set curvalue = curvalue + Increment_x
set curv = curv + chadd
set xcastnum = xcastnum + 1
end repeat
end if
updatestage
set the floatPrecision = 2
end
-- Draw the chart
--
-- recieves bomber - main airplane
-- basher - airplane to display data about
-- chrite - sprite channel to use for drawing
--
-- for main line pass same plane for bomber and basher
on chewchart bomber,basher, chrite
global Start_x, End_x, Start_y, End_y, Increment_x, Increment_y
global cLabel_x, cLabel_y, cParam_name, cParam_value
global currentChartName, fixedchartname
if start_y = end_y then
set end_y = 1000
set start_y = 0
end if
set cParam_value = the text of member "current param"
if word 2 of cParam_value = "nm" then
set cParam_value = word 1 of cParam_value
end if
-- open query based on chart name
set queryname = fixedchartname & "Values"
set qdHandle =DGQDOpen(queryname,dbHandle)
if qdHandle="#ERROR#" then
alert "Error:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Bomb Plane", bomber, qdhandle) = "#ERROR#" then
alert "bomb:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Model", basher, qdhandle) = "#ERROR#" then
alert "model:"&&GetLastDGError()
end if
if cParam_name <> "" then
-- if cParam_value = "Sea Level" then set cParam_value = 0
if DGQDsetParameterValue(cParam_name, cParam_value, qdhandle) = "#ERROR#" then
alert cParam_name&&GetLastDGError()&& "="&&cParam_value
end if
end if
set rsHandle=DGQDCreateRS(qdHandle)
if rsHandle = "#ERROR#" then
alert "DB error"
else
set foundcount = DGRSGetFieldCount(rsHandle)
puppetSprite chrite, true
if cLabel_x <> "" then set x1 = DGRSGetFieldValue(cLabel_x,rsHandle)
if x1 <> "#ERROR#" then
if cLabel_y <> "" then set y1 = DGRSGetFieldValuech(cLabel_y,rsHandle)
if y1 <> "#ERROR#" then
-- hard wired for the 2 charts that have only 1 set of numbers
if fixedChartName = "Landing_Distance" then
if bomber = basher then
drawaline(chrite, Start_x, ((End_y-start_x)*.05), x1, ((End_y-start_x)*.05))
else
drawaline(chrite, Start_x, ((End_y-start_x)*.1), x1, ((End_y-start_x)*.1))
end if
else
if fixedChartName = "Time_to_Climb" then
drawaline(chrite, start_x, start_y, x1, y1)
else
-- generic chart behavior
repeat while true
if DGRSIsEof(rsHandle) then exit repeat
set x2 = DGRSGetFieldValuech(cLabel_x,rsHandle)
set y2 = DGRSGetFieldValuech(cLabel_y,rsHandle)
drawaline(chrite, x1, y1, x2, y2)
set x1 = x2
set y1 = y2
DGRSMoveNext(rsHandle)
end repeat
end if
end if
else alert("No Data Available For Selected Plane/Configuration")
else alert("No Data Available For Selected Plane/Configuration")
end if
puppetSprite chrite, false
-- close database
if DGQDIsOpen(qdhandle) then
DGQDClose(qdhandle)
end if
if DGRSIsOpen(rsHandle) then
DGRSClose(rsHandle)
end if
set the loch of sprite chrite = -1000
set the locv of sprite chrite = 1000
updatestage
end